package com.eclipse.training.ui;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

import com.eclipse.training.model.Asteroid;
import com.eclipse.training.model.DarkMatter;
import com.eclipse.training.model.Galaxy;
import com.eclipse.training.model.GalaxyCluster;
import com.eclipse.training.model.Nebula;
import com.eclipse.training.model.Planet;
import com.eclipse.training.model.Satellite;
import com.eclipse.training.model.SolarSystem;
import com.eclipse.training.model.Star;
import com.eclipse.training.model.StarCluster;

public class TableLabelProvider implements ITableLabelProvider {

	@Override
	public void addListener(ILabelProviderListener arg0) {
	}

	@Override
	public void dispose() {
	}

	@Override
	public boolean isLabelProperty(Object arg0, String arg1) {
		return false;
	}

	@Override
	public void removeListener(ILabelProviderListener arg0) {
	}

	@Override
	public Image getColumnImage(Object arg0, int arg1) {
		return null;
	}

	@Override
	public String getColumnText(Object element, int columns) {

		if (element instanceof Asteroid) {
			return element.toString();
		} else if (element instanceof DarkMatter) {
			return element.toString();
		} else if (element instanceof Galaxy) {
			return element.toString();
		} else if (element instanceof GalaxyCluster) {
			return element.toString();
		} else if (element instanceof Nebula) {
			return element.toString();
		} else if (element instanceof Planet) {
			return element.toString() + " Rev = "
					+ ((Planet) element).getRevPeriod() + " Rot = "
					+ ((Planet) element).getRotPeriod();
		} else if (element instanceof Satellite) {
			return element.toString() + " Rev = "
					+ ((Satellite) element).getRevPeriod() + " Rot ="
					+ ((Satellite) element).getRotPeriod();
		} else if (element instanceof SolarSystem) {
			return element.toString();
		} else if (element instanceof Star) {
			return element.toString() + " Class = "
					+ ((Star) element).getStarClass();
		} else if (element instanceof StarCluster) {
			return element.toString();
		}

		return null;
	}

}
